Public Class frmTheCongNo1
    Private Sub loadNhaCungCap()
        Dim sqlQuery As String = "SELECT ma_nhacungcap, ten_nhacungcap FROM tbl_nhacungcap ORDER BY ten_nhacungcap"
        Dim dataNhaCungCap As DataTable = moduleDatabaseConn.GetDataTable(sqlQuery)
        mcbNhaCungCap.Items.Clear()
        mcbNhaCungCap.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
        mcbNhaCungCap.ColumnNum = 2
        mcbNhaCungCap.ColumnWidth = "102;347"
        mcbNhaCungCap.HighlightBorderColor = Color.Black
        mcbNhaCungCap.GridLineHorizontal = True
        mcbNhaCungCap.GridLineVertical = True
        mcbNhaCungCap.ItemHeight = 16
        mcbNhaCungCap.DropDownHeight = 150
        mcbNhaCungCap.SourceDataTable = dataNhaCungCap
        mcbNhaCungCap.SelectedIndex = 0
    End Sub

    Private Sub loadKhachHang()
        Dim sqlQuery As String = "SELECT ma_nhacungcap, ten_nhacungcap FROM tbl_khachhang WHERE ma_nhom <> 'KT' ORDER BY ten_nhacungcap"
        Dim dataKhachHang As DataTable = moduleDatabaseConn.GetDataTable(sqlQuery)
        mcbNhaCungCap.Items.Clear()
        mcbNhaCungCap.LoadingType = MTGCComboBox.CaricamentoCombo.DataTable
        mcbNhaCungCap.ColumnNum = 2
        mcbNhaCungCap.ColumnWidth = "102;347"
        mcbNhaCungCap.HighlightBorderColor = Color.Black
        mcbNhaCungCap.GridLineHorizontal = True
        mcbNhaCungCap.GridLineVertical = True
        mcbNhaCungCap.ItemHeight = 16
        mcbNhaCungCap.DropDownHeight = 150
        mcbNhaCungCap.SourceDataTable = dataKhachHang
        mcbNhaCungCap.SelectedIndex = 0
    End Sub

    Private Sub frmTheCongNo_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        moduleUtils.setDinhDangVietNam()
        Me.DPTTuNgay.Text = moduleUtils.getNgayDauThang(Today.Year, Today.Month)
        Me.DPTDenNgay.Text = moduleUtils.getNgayCuoiThang(Today.Year, Today.Month)
        Me.Alert_Max.Checked = True
        Me.Alert_Min.Checked = False
    End Sub

    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        Me.Close()
        Me.Dispose()
    End Sub

    Private Sub btnInBaoCao_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInBaoCao.Click

        If Alert_Max.Checked = True Then
            congno.tinhTheCongNo_NhaCungCap(CDate(Me.DPTTuNgay.Text.Trim), CDate(Me.DPTDenNgay.Text.Trim), Me.mcbNhaCungCap.Text.Trim, 1)
            Dim myForm As New FrmCrTheCongNo_NhaCungCap
            myForm.setTenncc(Me.txtTenNhaCungCap.Text)
            myForm.setThangnam(CDate(Me.DPTTuNgay.Text))
            myForm.Show()
        Else
            congno.tinhTheCongNo_KhachHang(CDate(Me.DPTTuNgay.Text.Trim), CDate(Me.DPTDenNgay.Text.Trim), Me.mcbNhaCungCap.Text.Trim, 1)
            Dim myForm As New FrmCrTheCongNo_KhachHang
            myForm.setTenkh(Me.txtTenNhaCungCap.Text)
            myForm.setThangnam(CDate(Me.DPTTuNgay.Text))
            myForm.Show()
        End If
    End Sub

    Private Sub Alert_Max_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Alert_Max.CheckedChanged
        loadNhaCungCap()
    End Sub

    Private Sub Alert_Min_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Alert_Min.CheckedChanged
        loadKhachHang()
    End Sub

    Private Sub mcbNhaCungCap_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles mcbNhaCungCap.SelectedIndexChanged
        If mcbNhaCungCap.Text <> "" Then
            Me.txtTenNhaCungCap.Text = Me.mcbNhaCungCap.SelectedItem.Col2
        Else
            Me.txtTenNhaCungCap.Text = " "
        End If
    End Sub

End Class